module.exports = class extends think.Controller {
    async __before() {
        if (!this.isPost) {
            return this.fail('请求方式错误，请用post请求');
        }
        // 根据token值获取用户id
        think.token = this.ctx.header['xiaoju-token'] || '';
        //return this.fail(think.token);
        if (think.token === '') {
            think.user = {user_id: 0};
        } else {
            const tokenSerivce = think.service('token');
            think.user = await tokenSerivce.getUserToken();
            if (think.user.user_id <= 0) {
                return this.fail('登录失效');
            }
        }
    }
};
